<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>下拉菜单</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        .box-1{
            width: 100px;
            margin: 100px auto;
            position: relative;
        }
        li{
            list-style: none;
        }
        button{
            width: 100px;
            height: 40px;
            background: #000000;
            border: none;
            outline: none;
            color: white;
            font-size: 14px;
        }
        ul{
            overflow: hidden;
            height: 0;
            transition: all .5s;
            position: absolute;
        }
        ul li{
            width: 100px;
            height: 40px;
            text-align: center;
            line-height: 40px;
            background: #2F3430;
            color: white;
            font-size: 14px;
            cursor: pointer;
        }
        ul li:hover{
            background: #3C3C3C;
        }






    </style>
</head>
<body>
<div class="box-1">
    <button id="btn">你点我啊</button>
    <ul id="ul">
        <li>点我干嘛?</li>
        <li>啊?</li>
        <li>啊??</li>
        <li>啊???</li>
    </ul>
</div>
<a href="8-5-work-2.html">电灯泡</a>
</body>
<script>
    var kg = false
    var btn = document.getElementById('btn')
    var ul = document.getElementById('ul')
    btn.onclick = function () {
        if (kg){
            ul.style.overflow = 'hidden'
            ul.style.height = '0'
            ul.style.transition = 'all .5s'
            kg = false
        }
        else {
            ul.style.overflow = 'none'
            ul.style.height = '160px'
            kg = true
        }
    }


    var i = 0
    function off(e) {
        if (i==0){
            e.src = 'img/on.jpg'
            i = 1
        }
        else {
            e.src = 'img/off.jpg'
            i = 0
        }
    }
</script>
</html>